<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="UTF-8"%>
<%@ page import="org.vo.*,org.factory.*,org.dao.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<% request.setCharacterEncoding("utf-8"); %>
<title>更新。。。</title>
</head>
<body>
  <%
     User user=new User();
     UserDAO dao=DAOFactory.getUserDAOInstance();
     String name=null,sex=null,mail=null,passwd=null,date=null;
     int id=0,age=0;
     try{
    	 id=Integer.parseInt(request.getParameter("aid")); 
    	 name=request.getParameter("bname");             //为什么index页面姓名对应的input的nam值改为"name",或者姓名、性别等name属性开头如果是同一个字母就会出错？？？？？？
    	 sex=request.getParameter("csex");
    	 age=Integer.parseInt(request.getParameter("dage"));
    	 mail=request.getParameter("email");
    	 passwd=request.getParameter("fpasswd");
    	 date=request.getParameter("gdate");
  
    	 
     }catch(Exception e){
   %>
     <script>alert("信息格式错误，请核对哦亲");</script>
   <%
     response.setHeader("Refresh", "0;URL=index.jsp"); //更新失败，跳转回用户信息页面
     }
     user.setId(id);
     user.setName(name);
     user.setSex(sex);
     user.setAge(age);
     user.setMail(mail);
     user.setPasswd(passwd);
     dao.update(user);                               //更新user
     UserDAO dao2=DAOFactory.getUserDAOInstance();
     User user2=dao2.findById(id);  
     session.setAttribute("user",user2);             //重新设置session的user值
     response.setHeader("Refresh", "0;URL=index.jsp");  
  %>
</body>
</html>